package com.mxt.moviedemo.controller;

import com.mxt.moviedemo.entity.Movies;
import com.mxt.moviedemo.service.MoviesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class MoviesController {

    @Autowired
    private MoviesService moviesService;

    @GetMapping("/movieInfo")
    public String showMovieInfo(@RequestParam("mid") int mid,
                                @RequestParam(name = "username", required = false) String username,
                                Model model) {
        // 根据电影ID获取电影信息
        Movies movie = moviesService.getMovieById(mid);
        model.addAttribute("movie", movie);
        model.addAttribute("username", username);
        return "movieInfo";
    }
}